<template>
  <view
    class="content"
    :style="{
      'padding-top': height + 'px',
	  'box-sizing':'border-box',
    }"
  >
    <view
      :style="{
        width: '100%',
        height: statusBarHeight + 'px',
        background: 'white',
        position: 'fixed',
        top: 0,
        zIndex: 100,
      }"
    >
    </view>
    <view
      class="head"
      :style="{
        top: statusBarHeight + 'px',
		background:'white'
      }"
    >
      <view class="head_left">
        <u-icon
          name="arrow-left"
          color="#444444"
          size="24"
          :bold="true"
          @click="toBack"
        ></u-icon>
      </view>
      <view class="">
        {{ datas.name }}
      </view>
      <view class="head_right">
        <view class="zhuan">
          <image
            src="@/static/images/slices/icon_bai_zhunfa.png"
            mode=""
          ></image>
        </view>
      </view>
    </view>

    <view class="box" :style="{marginTop:statusBarHeight+height+'px'}">
      <view class="box_head">
        <view class="box_head_left">
          <image :src="datas.img_avatar_url" mode=""></image>
        </view>
        <view class="box_head_right">
          <view class="box_head_right_title">
            <view class="box_head_right_title_left">
              {{ datas.name }}
            </view>
          </view>
          <view class="box_head_right_member">
            {{ datas.create_time }}创建
          </view>
        </view>
      </view>
      <view class="start_host" @click="toUser">
        <view class="host_left"> 星主 </view>
        <view class="host_right" v-if="datas.user">
          <image :src="datas.user.avatar_url" mode=""></image>
          <text class="host_right_text">{{ datas.user.nick_name }}</text>
          <u-icon name="arrow-right" color="#ADADAD" size="18"></u-icon>
        </view>
      </view>
	<!-- v-if="shenfen != 0" -->
      <view class="start_host" >
        <view class="host_left"> 星球成员 </view>
        <view class="host_right" v-if="datas.user" @click="toDetail">
          <!-- <image :src="datas.user.avatar_url" mode=""></image> -->
          <text class="host_right_text">{{ datas.people_total }}成员</text>
          <u-icon name="arrow-right" color="#ADADAD" size="18"></u-icon>
        </view>
      </view>
      <view class="box_content">
        <view class="box_content_title"> 星球简介 </view>
        <view class="box_content_text">
          {{ datas.introduce }}
        </view>
      </view>
      <view class="box_content">
        <view class="box_content_title"> 发言规则 </view>
        <view class="box_content_text">
          {{ datas.rule }}
        </view>
      </view>
      <view class="discussion">
        <view class="discussion_title"> 友情星球 </view>
        <view class="discussion_box">
          <co-create-item
            v-for="(item, index) in youqing"
            :type="index"
            :item="item"
          ></co-create-item>
        </view>
      </view>
    </view>
	<floatingBall></floatingBall>
  </view>
</template>

<script>
import CoCreateItem from "./components/coCreateItem.vue";
import { Detail } from "@/common/api/start.js";
export default {
  data() {
    return {
      statusBarHeight: 0,
      height: 0,
      datas: {},
      id: -1,
      youqing: [],
      shenfen: 0,
    };
  },
  components: {
    CoCreateItem,
  },
  created() {
    const statusBarHeight = uni.getSystemInfoSync(); // 获取手机状态栏高度

    const windowHeihgt = statusBarHeight.windowHeight;
    this.statusBarHeight = statusBarHeight.statusBarHeight;
    this.$nextTick(() => {
      uni
        .createSelectorQuery()
        .select(".head")
        .boundingClientRect((data) => {
          this.height = data.height;
        })
        .exec();
    });
  },
  onLoad(options) {
    if (options && options.id) {
      this.id = options.id;
      this.getDetail();
    }
  },
  methods: {
    toBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
    getDetail(id) {
      Detail({
        id: this.id,
      }).then((res) => {
        console.log("ressss", res.data.detail);
        this.datas = res.data.detail.info;
        this.youqing = res.data.detail.youqing;
        this.shenfen = res.data.detail.shenfen;
      });
    },
    toDetail() {
      uni.navigateTo({
        url:
          "/pages/distinguish/member?id=" +
          this.id +
          "&shenfen=" +
          this.shenfen +
          "&user_id=" +
          this.datas.user.user_id,
      });
    },
    toUser() {
      console.log("dddddddatadata", this.datas);
      uni.navigateTo({
        url: `/pages/home/home?user_id=${this.datas.user_id}`,
      });
    },
  },
};
</script>

<style scoped lang="scss">
.content {
  box-sizing: border-box;
}

.head {
  width: 100%;
  padding: 18rpx 30rpx 47rpx;
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  z-index: 99;

  .head_left {
    position: absolute;
    left: 30rpx;
  }

  .head_right {
    position: absolute;
    right: 30rpx;
    color: #55b877;
  }

  .text {
    font-size: 36rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: 400;
    color: #444444;
  }
}
.zhuan {
  width: 40rpx;
  height: 38rpx;
  margin-left: 40rpx;

  image {
    width: 100%;
    height: 100%;
  }
}
.box {
  width: 100%;
  padding: 0 30rpx;
  box-sizing: border-box;
  .box_head {
    width: 100%;
    display: flex;

    margin-top: 24rpx;

    .box_head_left {
      width: 124rpx;
      height: 124rpx;

      image {
        width: 100%;
        height: 100%;
        border-radius: 16rpx;
      }
    }

    .box_head_right {
      flex: 1;
      padding-left: 24rpx;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .box_head_right_title {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 32rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        color: #474747;
      }
      .box_head_right_member {
        font-size: 28rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        color: #888888;
      }
    }
  }

  .start_host {
    width: 100%;
    height: 106rpx;
    background: #f7f8fa;
    border-radius: 16rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32rpx;
    box-sizing: border-box;
    margin-top: 40rpx;
    .host_left {
      font-size: 28rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      color: #444444;
    }
    .host_right {
      display: flex;
      align-items: center;
      image {
        width: 56rpx;
        height: 56rpx;
        margin-right: 16rpx;
        border-radius: 50%;
      }
      .host_right_text {
        margin-right: 16rpx;
      }
      font-size: 24rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      color: #444444;
    }
  }
  .box_content {
    margin-top: 40rpx;
    .box_content_title {
      font-size: 30rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      color: #444444;
    }
    .box_content_text {
      font-size: 26rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      color: #444444;
      line-height: 42rpx;
      margin-top: 16rpx;
    }
  }
  .discussion {
    width: 100%;
    margin-top: 40rpx;
    .discussion_title {
      width: 100%;
      font-size: 30rpx;
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      color: #444444;
    }
    .discussion_box {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
    }
  }
}
</style>